﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FineUI;
using SysManage.BLL;
using ZHDJ.Core;
using ZHDJ.Core.Util;
using ZHDJ.Data.DataCaching;
using ZHDJ.Data.Models.BaseInfo;
using ZHDJ.Data.Models.Edu;
using ZHDJ.WebPage;

namespace SysManage.Module.Edu
{
    public partial class PartyEduCoursewareSelectEdit : PageBase
    {
        #region ViewPower

        /// <summary>
        /// 本页面的浏览权限，空字符串表示本页面不受权限控制
        /// </summary>
        public override string ViewPower
        {
            get
            {
                return "";
            }
        }

        #endregion

        #region Page_Load

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindData();
                LoadData();
            }
        }
        private void BindData()
        {
            hdFileId.Text = Request.QueryString["Lessonid"];
            ddlPartyEduLesson.DataSource = PartyEduCourseware.GetPartyEduCourseware(0, 1000, "", "");

            ddlPartyEduLesson.DataTextField = "Title";
            ddlPartyEduLesson.DataValueField = "Id";

            ddlPartyEduLesson.DataBind();
        }
        private void LoadData()
        {

        }

        #endregion

        #region Events


        protected void btnSaveClose_Click(object sender, EventArgs e)
        {
            var relation = new PartyeduLessonCourseRelation();
            relation.ID = StringHelper.NewID;
            relation.LessonId = hdFileId.Text;
            relation.CoursewareId = ddlPartyEduLesson.SelectedValue;
            relation.SortNo = int.Parse(txtSortNo.Text);

            DB.PartyeduLessonCourseRelations.Add(relation);
            DB.SaveChanges();
            PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
        }
        #endregion
        protected void btnClose_Click(object sender, EventArgs e)
        {
            PageContext.RegisterStartupScript(ActiveWindow.GetHideReference());
        }
    }
}
